<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="insertar.aspx.cs" Inherits="GesWork.maestros.insertar" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


    <asp:content ID="df" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
      
       <div class="recuadro">
                        <b>Propietario:</b>
                        <asp:Label ID="OwnerLabel" runat="server" 
                            Text='<%# User.Identity.Name %>' /> 
                        
                            
                        
                       <br /><br />
                         <div class="separador"></div>   
                        <br />

 <b>Tipo:</b>
                        
                        <asp:DropDownList ID="cmbACC_TypeTextBox" runat="server"   
                            
                            DataTextField="description" DataValueField="id" 
                            onselectedindexchanged="TipoRelacionInsert" DataSourceID="dsTipo" 
                              >
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="dsTipo" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [description], [id] FROM [ActivityType]">
                        </asp:SqlDataSource>
                        <br />
                        <b>Estado:</b>
                        <asp:DropDownList ID="cmbACC_StateTextBox" runat="server"   
                            
                            DataTextField="Description" DataValueField="ID" DataSourceID="dsEstado" 
                             >
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="dsEstado" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [Description], [ID] FROM [ActivityState]">
                        </asp:SqlDataSource>
                        <br />
                        <b>Prioridad:</b>
                        <asp:DropDownList ID="cmbACC_IDPriorityTextBox" runat="server"   
                           
                            DataTextField="Description" DataValueField="ID" DataSourceID="dsPrioridad" 
                             >
                        </asp:DropDownList>
                        
                        <asp:SqlDataSource ID="dsPrioridad" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [Description], [ID] FROM [ActivityPriority]">
                        </asp:SqlDataSource>
                        
                        <br />
                        <b>Categoria:</b>
                        <asp:TextBox ID="ACC_CategoriesTextBox" runat="server" 
                            />
                        
                        <br /><br />
                         <div class="separador"></div>   
                        <br />
                       
                     <asp:UpdatePanel runat="server" ID="updPanel">
                     <ContentTemplate>
                     
                        <b>Tipo de relacion:</b>

                            <asp:DropDownList ID="cmbOwnerByTypeIns" runat="server"  
                               AutoPostBack="True"  OnSelectedIndexChanged="TipoRelacionInsert"
                                 >
                            <asp:ListItem Text="Oportunidad" Value="0"></asp:ListItem>
                            <asp:ListItem Text="Empresa" Value="1"></asp:ListItem>
                            <asp:ListItem Text="Contacto" Value="2"></asp:ListItem>
                            </asp:DropDownList>
                        <br />
                        
                        <b>Relacionado con:</b>
                         <asp:DropDownList ID="CmbIDToUserIns" runat="server" 
                            DataSourceID="dsOportunityIns" DataTextField="Name" DataValueField="ID"  
                                >
                            </asp:DropDownList>
                         
                         <br /><br />
                         <div class="separador"></div>   
                        <br />
                       
                        <asp:SqlDataSource ID="dsContactIns" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [Name]+' '+[FirstName]+' '+[LastName] as Name, [ID] FROM [Contact] ORDER BY FirstName"></asp:SqlDataSource>
                        <asp:SqlDataSource ID="dsEnterpriseIns" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [Name], [ID] FROM [Enterprise]"></asp:SqlDataSource>
                        <asp:SqlDataSource ID="dsOportunityIns" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                            SelectCommand="SELECT [Name], [ID] FROM [Oportunity]"></asp:SqlDataSource>

                            
                           
                       </ContentTemplate>
                     </asp:UpdatePanel>
                     
                        
                       
                            
                           
                       
                        
                       
                        
                        <b>Asunto:</b>
                        <asp:TextBox ID="SubjectTextBox" runat="server" ></asp:TextBox>
                        <br />
                        <b>Detalle:</b>
                        <asp:TextBox ID="MSG_TextTextBox" runat="server" Height="200px" 
                            TextMode="MultiLine" Width="600px" 
                             />
                        <br />
                        <b>Fecha de Inicio:</b>
                        <asp:TextBox ID="StartDateTextBox" runat="server" 
                           />
                            <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="StartDateTextBox" FirstDayOfWeek="Monday" Format="dd/MM/yyyy">
                            </cc1:CalendarExtender>
                        <br />
                        <b>Fecha de Fin:</b>
                        <asp:TextBox ID="DueDateTextBox" runat="server"  />
                        <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="DueDateTextBox" FirstDayOfWeek="Monday" Format="dd/MM/yyyy">
                            </cc1:CalendarExtender>
                       
                        <br />
                         <b>Dura todo el dia:</b>
                        <asp:CheckBox ID="AllDayEventCheckBox" runat="server" 
                            />
                        <br /><br />
                         <div class="separador"></div>   
                        <br />
                        
                       
                        
                    <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                     <ContentTemplate>
                   
                        <b>Parentesco:</b>
                        <asp:TextBox ID="ACC_IDParentActivityTextBox" runat="server" />
                        
                            
                <asp:ImageButton ID="lnkAddParent" runat="server"   
                 ImageUrl="~/images/btnAniadir.png"  CausesValidation="False"  style="position:relative; float:inherit;margin-left:420px;"
                    CommandName="New" />   
                        <br />
                        
                        
                        <asp:Panel runat="server" ID="pnlActividades" CssClass="modalPopup">


<script language="javascript">
function SetUniqueRadioButton(nameregex, rid)
    {
       re = new RegExp(nameregex);
       rb = document.getElementById(rid.id);
       var inputs = document.getElementsByTagName('input');
       for(i = 0; i < inputs.length; i++)
       {
          elm = inputs[i]
          if (elm.type == 'radio')
          {
             if (re.test(elm.name))
             {
                elm.checked = false;
             }
          }
       }
 
       rb.checked = true;
    }

</script>
                                           <table class="tblGeneral" >
                                                <tr class="tblHeader">
                                                        <td>
                                                        
                                                        </td>
                                                        <td>
                                                        <b>Tipo</b>
                                                        </td>
                                                        <td>
                                                        <b>Tarea</b>
                                                        </td>
                                                        
                                                        <td>
                                                        <b>Fecha de Inicio</b>
                                                        </td>
                                                        
                                                        

                                                    </tr>
                                                    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                                                    <ItemTemplate>
                                                    <tr>
                                                        <td>
                                                        <asp:RadioButton  runat="server" ID="activ" onclick=" SetUniqueRadioButton('Repeater1.*', this)"  /> 
                                                        <asp:Label  runat="server" ID="lblID" Text='<%# Eval("ID") %>' Visible="false" />
                                                        </td>
                                                        <td>
                                                        <img src="../images/activitytype<%# Eval("ACC_Type")%>.png"  alt="Actividad" name="Actividad"/>
                                                        </td>
                                                        <td>
                                                          <%# Eval("Subject")%> 
                                                        </td>
                                                        
                                                        <td>
                                                        <%# Eval("StartDate", "{0:dd/MM/yyyy}")%>
                                                        </td>
                                                       
                                                       

                                                    </tr>
                                                    </ItemTemplate>
                                                    </asp:Repeater>
                                                </table>
                                        
                                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                                            
                                                    SelectCommand="SELECT Activity.ID, Activity.Subject, Activity.StartDate, Activity.ACC_IDPriority ,ActivityPriority.Description AS priority, Activity.ACC_Type
                                    FROM Activity, ActivityPriority WHERE ACC_IDPriority=ActivityPriority.ID  ORDER BY StartDate ">
                                        </asp:SqlDataSource>
                <br/>
                                    <asp:ImageButton ID="btnSelectActivity" runat="server"  OnClick="btnSelectActivity_Click" ImageUrl="~/images/btnAceptar.png" AlternateText="Aceptar"/>
                                    <asp:ImageButton ID="CancelButton" runat="server" ImageUrl="~/images/btnCancelar.png"  AlternateText="Cancelar"/>
                </asp:Panel>
                
                
                <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"  
                            TargetControlID="lnkAddParent" PopupControlID="pnlActividades"
                             BackgroundCssClass="modalBackground" 
                            DropShadow="true" 
                            
                           
                            CancelControlID="CancelButton" 
                            
                           
                        >
                </cc1:ModalPopupExtender>
                
              </ContentTemplate>
              </asp:UpdatePanel>
            
            <asp:SqlDataSource ID="dsActividades" runat="server" 
                ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                
                    InsertCommand="INSERT INTO [Activity] ([IDOwner], [OwnerByType], [IDToUser], [Subject], [MSG_Text], [StartDate], [DueDate], [ACC_Type], [ACC_State], [ACC_IDPriority], [ACC_Categories], [ACC_IDCampaign], [ACC_IDParentActivity], [FaxOrPhone], [AllDayEvent], [Layout], [RecurrencePattern]) VALUES (@Owner, @OwnerByType, @IDToUser, @Subject, @MSG_Text, @StartDate, @DueDate, @ACC_Type, @ACC_State, @ACC_IDPriority, @ACC_Categories, @ACC_IDCampaign, @ACC_IDParentActivity, @FaxOrPhone, @AllDayEvent, @Layout, @RecurrencePattern)" >
               
                <InsertParameters>
                    <asp:Parameter Name="Owner" Type="String" />
                    <asp:Parameter Name="OwnerByType" Type="Int32" />
                    <asp:Parameter Name="IDToUser" Type="String" />
                    <asp:Parameter Name="Subject" Type="String" />
                    <asp:Parameter Name="MSG_Text" Type="String" />       
                    <asp:Parameter Name="StartDate" Type="String"/>
                    <asp:Parameter Name="DueDate" Type="String" />
                    <asp:Parameter Name="ACC_Type" Type="Int32" />
                    <asp:Parameter Name="ACC_State" Type="Int32" />
                    <asp:Parameter Name="ACC_IDPriority" Type="Int32" />
                    <asp:Parameter Name="ACC_Categories" Type="String" />
                    <asp:Parameter Name="ACC_IDCampaign" Type="String" />
                    <asp:Parameter Name="ACC_IDParentActivity" Type="String" />
                    <asp:Parameter Name="FaxOrPhone" Type="String" />
                    <asp:Parameter Name="AllDayEvent" Type="Boolean" />
                    <asp:Parameter Name="Layout" Type="String" />
                    <asp:Parameter Name="RecurrencePattern" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
    
    
       
    
     
    <br /><br />
                         <div class="separador"></div>   
                        <br />
                        
                
<asp:ImageButton ID="InsertButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" onclick="btnInsertar_Click" Text="Guardar" />
                
<asp:ImageButton ID="UpdateCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" Text="Cancelar"  PostBackUrl="~/actividades/activas.aspx" />
    
    </div>
       
    
    
    
    <br />
</p>
<p>
</p>
    </asp:content>

